# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer: Alex Denes <caskd@redxen.eu>
pkgname=prometheus-postgres-exporter
_pkgname=postgres_exporter
pkgver=0.10.1
pkgrel=3
pkgdesc="Prometheus exporter for PostgreSQL database"
url="https://github.com/prometheus-community/postgres_exporter"
license="Apache-2.0"
arch="all !riscv64" # nonexistent riscv64 dependency downloaded at build time
makedepends="go>=1.14 bash sed"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/prometheus-community/postgres_exporter/archive/v$pkgver.tar.gz
	postgres-exporter.initd
	postgres-exporter.confd
	disable-go-race-detector.patch"
builddir="$srcdir/$_pkgname-$pkgver"
export GOFLAGS="$GOFLAGS -modcacherw"

build() {
	make build
}

check() {
	make test
}

package() {
	install -Dm755 postgres_exporter "$pkgdir"/usr/bin/postgres_exporter

	install -Dm755 "$srcdir"/postgres-exporter.initd "$pkgdir"/etc/init.d/postgres-exporter
	install -Dm644 "$srcdir"/postgres-exporter.confd "$pkgdir"/etc/conf.d/postgres-exporter
}

sha512sums="
75ba08354174980d55fb1deed1035323d89f3331f0c366165a0262b4081b99d083f14dbcdd7539836399d0d69a75a296cb978a42d94ff0b1c0bcb8f3933fcabc  postgres_exporter-0.10.1.tar.gz
aaac144cdf65d1106d91f02f0daad965a935d134885f706f872fef6e1e554c29c79bb17714727e6bad5df432b72bb38a23225b9d133dc379199dbd3a15b66aa2  postgres-exporter.initd
0aa9bec3601c9f23cb0af8e6837c2614a98936af6d74645f8a097667bbd8ed2cf646678188eeb1759a76e9a74aea808478ac7f2f5755c988de727b0bd02f7772  postgres-exporter.confd
0e916a9216fbf21865a3672a1159836993048de1112dc8ddbd4e8283264d7fe12c5a5e2b08adeced2db6d4d35feb799c59eae7e55d010d045e825b4a524ae5e2  disable-go-race-detector.patch
"
